<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSchoolTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('school_info', function (Blueprint $table) {
            $table->increments('id');
            $table->integer("user_id");
            $table->string('school_name');
            $table->string('address');
            $table->tinyInteger('status');
            $table->timestamps();
        });
        Schema::create('school_role_users', function (Blueprint $table) {
            $table->integer('role_id');
            $table->integer('user_id');
            $table->integer('school_id');
            $table->index(['role_id', 'user_id']);
            $table->timestamps();
        });

        Schema::create('school_roles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name', 50)->unique();
            $table->string('slug', 50)->unique();
            $table->timestamps();
        });

        Schema::create('school_like_users', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('student_id');
            $table->integer('teacher_id');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('school_info');
        Schema::dropIfExists('school_role_users');
        Schema::dropIfExists('school_roles');
        Schema::dropIfExists('school_like_users');
    }
}
